import 'package:flutter/material.dart';
import 'package:httpdio/network/dio_client.dart';
import 'package:httpdio/service/comment_service.dart';
import 'package:httpdio/service/post_service.dart';
import 'package:httpdio/service/user_service.dart';
import 'package:httpdio/utils/timestamp_utils.dart';
import 'package:provider/provider.dart';

import 'app.dart';

void main() {
  // 测试时间戳转换
  final timestamp = 1672531200.0; // 2023-01-01 00:00:00 UTC
  final date = TimestampUtils.fromJson(timestamp);
  print('转换后的日期: ${date?.toIso8601String()}'); // 2023-01-01T00:00:00.000Z

  // 测试格式化
  final formatted = TimestampUtils.format(date, pattern: 'yyyy年MM月dd日');
  print('格式化日期: $formatted'); // 2023年01月01日

  // 测试相对时间
  final now = DateTime.now();
  final fiveMinutesAgo = now.subtract(const Duration(minutes: 5));
  print('相对时间: ${TimestampUtils.relativeTime(fiveMinutesAgo)}'); // 5分钟前

  // 测试工作日计算
  final start = DateTime(2023, 1, 1); // 星期日
  final end = DateTime(2023, 1, 10); // 星期二
  final businessDays = TimestampUtils.businessDaysBetween(start, end);
  print('工作日数量: $businessDays'); // 6 (1月1日周日不算，1月2-6日，9-10日)
  runApp(
    MultiProvider(
        providers: [
          Provider(create: (context)=>DioClient()),
          Provider(create: (context) => UserService()),
          Provider(create: (context) => PostService()),
          Provider(create: (context) =>CommentService()),
        ],
        child: const MyApp()),
  );
}

